package com.john.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.john.bean.Analyse_4_1Bean;
import com.john.service.base.Analyse_4_1Service;

@RestController
public class Analyse_4_1Controller {
	
	@Autowired
	private Analyse_4_1Service analyse_4_1Service;
	
	@GetMapping("/getAnalyse_4_1Beans")
	public List<Analyse_4_1Bean> getAnalyse_4_1Beans() {
		return analyse_4_1Service.getAnalyse_4_1Beans();
	}
	
	
	@GetMapping("/getAnalyse_4_1Beans_format")
	public JSONObject getAnalyse_4_1Beans_format() {
		List<Analyse_4_1Bean> analyse_4_1Beans = analyse_4_1Service.getAnalyse_4_1Beans();
		JSONObject	json = new JSONObject();
		List<String> cate_idList = new ArrayList<String>();
		List<Double> sum_priceList = new ArrayList<Double>();
		for (Analyse_4_1Bean analyse : analyse_4_1Beans) {
			cate_idList.add(analyse.getCate_id());
			sum_priceList.add(analyse.getSum_price());
		}
		json.put("cate_id", cate_idList);
		json.put("sum_price", sum_priceList);
		return json;
	}
}
